<?php

/**
 * This is the model class for table "old_ticket".
 *
 * The followings are the available columns in table 'old_ticket':
 * @property string $ticket_id
 * @property integer $event_id
 * @property string $category_id
 * @property integer $user_id
 * @property string $price
 * @property string $note
 * @property string $time_update
 * @property string $time_stamp
 */
class OldTicket extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'old_ticket';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('event_id, category_id, user_id', 'required'),
			array('event_id, user_id', 'numerical', 'integerOnly'=>true),
			array('category_id', 'length', 'max'=>50),
			array('price', 'length', 'max'=>11),
			array('note', 'length', 'max'=>255),
			array('time_update, time_stamp', 'length', 'max'=>10),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('ticket_id, event_id, category_id, user_id, price, note, time_update, time_stamp', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ticket_id' => 'Ticket',
			'event_id' => 'Event',
			'category_id' => 'Category',
			'user_id' => 'User',
			'price' => 'Price',
			'note' => 'Note',
			'time_update' => 'Time Update',
			'time_stamp' => 'Time Stamp',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ticket_id',$this->ticket_id,true);
		$criteria->compare('event_id',$this->event_id);
		$criteria->compare('category_id',$this->category_id,true);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('price',$this->price,true);
		$criteria->compare('note',$this->note,true);
		$criteria->compare('time_update',$this->time_update,true);
		$criteria->compare('time_stamp',$this->time_stamp,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return OldTicket the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
